// login.go
package form

import (
	"github.com/martini-contrib/binding"
	"martini_template/componnet"
	"net/http"
)

//用户模块提交的所有form
type LoginForm struct {
	Username string `form:"username"`
	Password string `form:"password"`
	DeviceCode string `form:"device_code"`
	DeviceName string `form:"device_name"`
}

func (lf *LoginForm) Validate(errors binding.Errors, req *http.Request) binding.Errors {
	lf.Username = componnet.FilterString(lf.Username)
	lf.Password = componnet.FilterString(lf.Password)
	lf.DeviceCode = componnet.FilterString(lf.DeviceCode)
	lf.DeviceName = componnet.FilterString(lf.DeviceName)
	return errors
}
